package project.product.internal;

import java.io.Serializable;
import java.util.List;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import project.product.Stlye;
import project.product.StyleService;

public class StyleServiceImpl extends HibernateDaoSupport  implements StyleService{

    @Override
    public Stlye getStlye(Serializable id) {
        StringBuffer queryString = new StringBuffer(" FROM Stlye where id=?");
        List<Stlye> list = this.getHibernateTemplate().find(queryString.toString(), id);
        if (list.size() > 0) {
            return list.get(0);
        }
        return null;
    }

    @Override
    public List<Stlye> findByClothId(Serializable cloth_id) {
        StringBuffer queryString = new StringBuffer(" FROM Stlye where cloth_id=? AND shelves = ? ORDER BY order");
        return this.getHibernateTemplate().find(queryString.toString(), new Object[]{cloth_id,true});
    }
    @Override
    public List<Stlye> findByBrandId(Serializable brand_id) {
        StringBuffer queryString = new StringBuffer(" FROM Stlye where brand_id=? AND shelves = ? ORDER BY order");
        return this.getHibernateTemplate().find(queryString.toString(), new Object[]{brand_id,true});
    }
}
